package com.ruoyi.outpatient.controller;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.outpatient.domain.MedicalCostOutpatientInfo;
import com.ruoyi.outpatient.service.IMedicalCostOutpatientInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 门诊卡信息Controller
 * 
 * @author yyj
 * @date 2022-01-04
 */
@RestController
@RequestMapping("/outpatient/info")
public class MedicalCostOutpatientInfoController extends BaseController
{
    @Autowired
    private IMedicalCostOutpatientInfoService medicalCostOutpatientInfoService;

    /**
     * 查询门诊卡信息列表
     */
    @PreAuthorize("@ss.hasPermi('outpatient:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(MedicalCostOutpatientInfo medicalCostOutpatientInfo)
    {
        startPage();
        List<MedicalCostOutpatientInfo> list = medicalCostOutpatientInfoService.selectMedicalCostOutpatientInfoList(medicalCostOutpatientInfo);
        return getDataTable(list);
    }

    /**
     * 导出门诊卡信息列表
     */
    @PreAuthorize("@ss.hasPermi('outpatient:info:export')")
    @Log(title = "门诊卡信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MedicalCostOutpatientInfo medicalCostOutpatientInfo)
    {
        List<MedicalCostOutpatientInfo> list = medicalCostOutpatientInfoService.selectMedicalCostOutpatientInfoList(medicalCostOutpatientInfo);
        ExcelUtil<MedicalCostOutpatientInfo> util = new ExcelUtil<MedicalCostOutpatientInfo>(MedicalCostOutpatientInfo.class);
        util.exportExcel(response, list, "门诊卡信息数据");
    }

    /**
     * 获取门诊卡信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('outpatient:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(medicalCostOutpatientInfoService.selectMedicalCostOutpatientInfoById(id));
    }

    /**
     * 新增门诊卡信息
     */
    @PreAuthorize("@ss.hasPermi('outpatient:info:add')")
    @Log(title = "门诊卡信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MedicalCostOutpatientInfo medicalCostOutpatientInfo)
    {

        return toAjax(medicalCostOutpatientInfoService.insertMedicalCostOutpatientInfo(medicalCostOutpatientInfo));
    }

    /**
     * 修改门诊卡信息
     */
    @PreAuthorize("@ss.hasPermi('outpatient:info:edit')")
    @Log(title = "门诊卡信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MedicalCostOutpatientInfo medicalCostOutpatientInfo)
    {
        return toAjax(medicalCostOutpatientInfoService.updateMedicalCostOutpatientInfo(medicalCostOutpatientInfo));
    }

    /**
     * 删除门诊卡信息
     */
    @PreAuthorize("@ss.hasPermi('outpatient:info:remove')")
    @Log(title = "门诊卡信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(medicalCostOutpatientInfoService.deleteMedicalCostOutpatientInfoByIds(ids));
    }
}
